package com.example.yang.yixin.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.IdRes;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yang.yixin.R;

public class BaseActivity extends Activity {
    private ImageView mIv_back,mIv_me,mIv_resource,mIv_person,mIv_details;
    private TextView mTitle;

    /*
             findViewbyid的简写
     */
    public <T extends View> T fd(@IdRes int id){
        return findViewById(id);
    }




    /*
                 增强narvbar的通用性
         */
    protected void initNarvBar(boolean isShowBack,String Title,boolean isShowMe){
       mIv_back=fd(R.id.iv_back);
       mIv_me=fd(R.id.iv_me);
       mTitle=fd(R.id.tv_title);
       mIv_back.setVisibility(isShowBack?View.VISIBLE:View.GONE);
        mIv_me.setVisibility(isShowMe? View.VISIBLE:View.GONE);
        mTitle.setText(Title);



        mIv_me.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                String username=getIntent().getStringExtra("data");
                intent.putExtra("data",username);
                intent.setClass(v.getContext(),MeActivity.class);
                startActivity(intent);
                startActivity(intent);
            }
        });


    }
    protected void initBottombar(View v){
        mIv_resource=fd(R.id.Iv_resource);
        mIv_person=fd(R.id.Iv_person);
        mIv_details=fd(R.id.Iv_details);
        mIv_resource.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(v.getContext(),BankeActivity.class);
                startActivity(intent);



            }
        });
        mIv_details.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClass(v.getContext(),DetialsActivity.class);
                startActivity(intent);


            }
        });
        mIv_person.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                String bkpassword=getIntent().getStringExtra("bkpassword");
                String username=getIntent().getStringExtra("data");
                intent.setClass(v.getContext(),PersonActivity.class);
                intent.putExtra("bkpassword",bkpassword);
                intent.putExtra("data",username);
                startActivity(intent);

            }
        });

    }

}
